﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace RaProWorld
{
    class Ltan_bg
    {
        Texture2D sprite1;
        Texture2D sprite2;
        Vector2 position1;
        Vector2 position2;

        public Ltan_bg(Texture2D[] newSprite) 
        {
            sprite1 = newSprite[0];
            sprite2 = newSprite[0];
            position1 = new Vector2(512.0f,384.0f);
            position2 = new Vector2(1536.0f,384.0f);
        }
        public void update(GameTime gameTime,bool isScrolling,float newSpeed) 
        {
            if (isScrolling) 
            {
                position1.X = position1.X - newSpeed;
                position2.X = position2.X - newSpeed;
                if (position1.X <= -512.0f) 
                {
                    position1.X = 512.0f;
                }
                if (position2.X <= 512.0f) 
                {
                    position2.X = 1536.0f;
                }
            }
        }
        public void reset() 
        {
            position1 = new Vector2(512.0f, 384.0f);
            position2 = new Vector2(1536.0f, 384.0f);
        }
        public void draw(SpriteBatch spriteBatch, GameTime gameTime) 
        {
            spriteBatch.Draw(sprite1,
                position1,
                null,
                Color.White,
                0.0f,
                new Vector2(sprite1.Width / 2, sprite1.Height / 2),
                1.0f,
                SpriteEffects.None,
                0);
            spriteBatch.Draw(sprite2,
                position2,
                null,
                Color.White,
                0.0f,
                new Vector2(sprite2.Width / 2, sprite2.Height / 2),
                1.0f,
                SpriteEffects.None,
                0);
        }
    }
}
